From 47f36b9da048720d588a21d1d7c2fbb0875d4295 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Thu, 8 Aug 2013 01:00:10 +0000 Subject: [PATCH] Fix mem clobber in tmpro. --- gpsbabel/tmpro.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gpsbabel/tmpro.cc b/gpsbabel/tmpro.cc index 0cc89866e..1f0089519 100644 --- a/gpsbabel/tmpro.cc +++ b/gpsbabel/tmpro.cc @@ -212,12 +212,11 @@ tmpro_waypt_pr(const waypoint * wpt) /* Number of characters */ /* 25 6 80 8 8 8 8 8 4 4 128 */ - const char *l; + const char *l = NULL; if (wpt->HasUrlLink()) { + // Yes, it's lame to allocate/copy here. UrlLink link = wpt->GetUrlLink(); - l = link.url_.toUtf8().data(); - } else { - l = ""; + l = xstrdup(link.url_.toUtf8().data()); } gbfprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n", shortname, @@ -237,6 +236,9 @@ tmpro_waypt_pr(const waypoint * wpt) if (shortname) { xfree(shortname); } + if (l) { + xfree(l); + } } static void -- 2.30.2